import { createRouter, createWebHistory } from 'vue-router';
import NProgress from 'nprogress'; // progress bar
import 'nprogress/nprogress.css';

import { customizedExternalRoutes } from './routes/index';
import { NOT_FOUND_ROUTE, REDIRECT_MAIN } from './routes/base';
import createRouteGuard from './guard';

NProgress.configure({ showSpinner: false }); // NProgress Configuration

const router = createRouter({
  history: createWebHistory(),
  routes: [
    {
      path: '/',
      redirect: '/sign-in',
    },
    // {
    //   path: '/login',
    //   name: 'login',
    //   component: () => import('@/views/login/index.vue'),
    //   meta: {
    //     requiresAuth: false,
    //   },
    // },
    {
      path: '/sign-in',
      name: 'SignIn',
      component: () => import('@/views/global/sign-in/index.vue'),
      meta: {
        requiresAuth: false,
      },
    },
    {
      path: '/sign-up',
      redirect: 'SignUpInfo',
      // name: 'SignUp',
      // component: DEFAULT_LAYOUT,
      children: [
        {
          path: '/sign-up-info',
          name: 'SignUpInfo',
          component: () => import('@/views/global/sign-up/info/index.vue'),
          meta: {
            locale: '员工注册',
            requiresAuth: false,
          },
        },
        {
          path: '/sign-up-auth-person',
          name: 'SignUpAuthPerson',
          component: () =>
            import('@/views/global/sign-up/auth-person/index.vue'),
          meta: {
            locale: '实名认证',
            requiresAuth: false,
          },
        },
      ],
    },
    // ...appRoutes,
    ...customizedExternalRoutes,
    REDIRECT_MAIN,
    NOT_FOUND_ROUTE,
  ],
  scrollBehavior() {
    return { top: 0 };
  },
});

createRouteGuard(router);

export default router;
